package com.nstc.demo.service.impl;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nstc.demo.dao.AimsAccountMapper;
import com.nstc.demo.dto.AimsAccountInfo;
import com.nstc.demo.dto.AimsAccountQueryParam;
import com.nstc.demo.entity.AimsAccount;
import com.nstc.demo.service.AimsAccountService;

@Service
public class AimsAccountServiceImpl implements AimsAccountService {
	@Autowired
	private AimsAccountMapper aimsAccountMapper;

	@Override
	public int add(AimsAccount record) {
		aimsAccountMapper.insertSelective(record);
		return record.getAccountid();

	}

	@Override
	public boolean deleteById(int id) {
		int changeRow = aimsAccountMapper.deleteByPrimaryKey(id);
		return changeRow >= 1;
	}

	@Override
	public boolean update(AimsAccount record) {
		int changeRow = aimsAccountMapper.updateByPrimaryKey(record);
		return changeRow >= 1;
	}


	@Override
	public PageInfo<AimsAccount> getPageWithCondition(int currentPage, int pageSize, AimsAccountQueryParam aimsAccountQueryParam) {
		// 使用分页插件开启分页
		PageHelper.startPage(currentPage, pageSize);
		List<AimsAccount> list = aimsAccountMapper.getListWithCondition(aimsAccountQueryParam);
		return new PageInfo<AimsAccount>(list);
	}

	@Override
	public AimsAccountInfo getInfoById(int id) {
		return aimsAccountMapper.getInfoById(id);
	}

	@Override
	public AimsAccount getById(int id) {
		return	aimsAccountMapper.selectByPrimaryKey(id);
	}

}
